<template>
  <div id="ContactUs">
   <van-form @submit="onSubmit" v-if="!show">
  <van-field
    v-model="username"
    name="用户名"
    label="用户名"
    placeholder="用户名"
    :rules="[{ required: true, message: '请填写用户名' }]"
  />
  <van-field
    v-model="password"
    type="password"
    name="密码"
    label="密码"
    placeholder="密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit">提交</van-button>
    <div class="zc cus" @click="show=true">没有账号? 去注册</div>
  </div>
  </van-form>

  <van-form @submit="onSubmit2" v-if="show">
  <van-field
    v-model="zc.acc"
    name="acc"
    label="用户名"
    placeholder="用户名"
    :rules="[{ required: true, message: '请填写公司名' }]"
  />
  <van-field
    v-model="password"
    type="password"
    name="mm"
    label="密码"
    placeholder="密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
   <van-field
    v-model="zc.mm"
    type="password"
    name="mm2"
    label="确认密码"
    placeholder="密码"
    :rules="[{ required: true, message: '确认密码' }]"
  />
   
   <van-field
    v-model="zc.lx"
    name="lx"
    label="联系人"
    placeholder="联系人"
    :rules="[{ required: true, message: '联系人' }]"
  />
   <van-field
    v-model="zc.phone"
   
    name="phone"
    label="手机号"
    placeholder="手机号"
    :rules="[{ required: true, message: '手机号' }]"
  />
   <van-field
    v-model="zc.zw"
    name="zw"
    label="职位"
    placeholder="职位"
    :rules="[{ required: true, message: '职位' }]"
  />
  <van-field
    v-model="zc.kp"
    name="kp"
    label="开票信息"
    placeholder="开票信息"
    :rules="[{ required: true, message: '开票信息' }]"
  />
   <el-upload
				  name="upFile"
				  class="upload-demo"
				  action="http://manage.jolinmind.cn/public/api/index/cusupload"
				  :on-success="changeWen"
				  :on-change="handleChange"
				  :before-remove="beforeRemove"
				  multiple				  			 
				  :file-list="fileList">
				  <el-button size="small" type="primary">点击上传</el-button>
				  <div slot="tip" class="el-upload__tip">上传开票文件</div>
				</el-upload>

  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit2">提交</van-button>
    <div class="zc cus" @click="show=false">已有账号? 去登录</div>
  </div>
  </van-form>
  </div>
</template>
<script>
import { WOW } from 'wowjs'
import BMap from "BMap";
import { Field } from 'vant';
export default {
  name: "Login",
  data() {
    return {
      fileList:[],
      show:false,
      username:'',
      password:'',
      zc:{

      },
      
    };
  },
 
  methods:{
   
   onSubmit(values) {
      console.log('submit', values);
    },
   onSubmit2(values) {
      let that=this;
      console.log('ww:',this.fileList);
      let ff=this.fileList;
      let f_arr=[];

       if(ff.length){
         for(let i in ff){
           f_arr.push(ff[i].response.data);
           
         };
       }else{
         f_arr=""
       };
       if(values.mm!=values.mm2){
         return alert('输入密码不相同')
       }

       console.log('f_arr:',f_arr,'c:',f_arr,);
      let data={
				company:values.acc,
				pwd:values.mm,
				lian1:values.lx,
				phone1:values.phone,
				job1:values.zw,
				ctext:values.kp,
				tfile:f_arr.length?f_arr.toString():''						
			};
      console.log('submit2', values,'55:',data);
     
     



    },
    beforeRemove(file, fileList) {
		        return this.$confirm(`确定移除 ${ file.name }？`);
		  },
      changeWen(e){
			console.log('ee:',e,'fileList:',this.fileList);
      //  this.fileList.push(e.data);
			// this.fileList=e.data;
		},
     handleChange(file, fileList) {
        this.fileList = fileList.slice(-3);
        // console.log('666:',fileList)
      },

  }
};
</script>
<style scoped>
.zc{
  margin-top: 10px;
}
.row {
  margin-right: 0;
  margin-left: 0;
}
@media screen and (max-width: 997px) {
  .ContactUs-container {
    padding: 20px 0;
  }
}
</style>

